<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:t="http://myfaces.apache.org/tomahawk">


    <ui:composition template="./WEB-INF/Templates/templateProjeto.xhtml">
        <ui:define name="titulo">consultaEmpreendimento</ui:define>

        <ui:define name="javascript">
            function controlaRadio(){
                var campo1 = document.getElementById("formFiltros:codAPF");
                var campo2 = document.getElementById("formFiltros:municipio");
                var radioSit1 = document.getElementById("formFiltros:selectSituacao:0");
                var radioSit2 = document.getElementById("formFiltros:selectSituacao:1");

                if(document.getElementById("formFiltros:radio0").checked){
                    campo1.disabled=false;
                    campo2.disabled=true;
                    radioSit1.disabled=true;
                    radioSit2.disabled=true;
                 }
                if(document.getElementById("formFiltros:radio1").checked){
                    campo1.disabled=true;
                    campo2.disabled=false;
                    radioSit1.disabled=true;
                    radioSit2.disabled=true;
                 }
                if(document.getElementById("formFiltros:radio2").checked){
                    campo1.disabled=true;
                    campo2.disabled=true;
                    radioSit1.disabled=false;
                    radioSit2.disabled=false;
                    radioSit1.checked="true";
                 }
            }
        </ui:define>
        <ui:define name="tituloH1">Selecione os filtros para sua pesquisa</ui:define>
        <ui:define name="pagLinda">
            <h1>Selecione os filtros para sua pesquisa - COLOCAR O BAGULHO PRA PESQUISAR TODOS</h1>
            <h:messages layout="list" style="color: darkred"/>
            <h:form id="formFiltros">
                <h:panelGrid columns="1">

                    
                    <h:panelGroup>
                        <!-- O atributo ONCHANGE fará com que toda vez que alguem clique num dos radio-buttons, a função controlaRadio() seja chamada -->
                        <t:selectOneRadio id="selectRadio" layout="spread" onchange="controlaRadio()" value="#{beanEmp.numRadioPesquisa}">
                            <f:selectItem itemLabel="Por código" itemValue="cod"  />
                            <f:selectItem itemLabel="Por código do municipio" itemValue="pcm"/>
                            <f:selectItem itemLabel="Por tipo de situação" itemValue="pts"/>
                        </t:selectOneRadio>

                        <t:radio for="selectRadio" index="0" id="radio0"/>
                    </h:panelGroup>
                    <h:panelGroup>
                 <!---->                      <!--Há 22 espaços invisiveis (alt+255) entre estes comentarios-->
                        <h:outputLabel value="Codigo APF"/>
                        <h:inputText id="codAPF" label="Codigo APF" value="#{beanEmp.empreendimento.codigoComDigito}">
                            <f:validateRequired/>
                            <f:validator validatorId="validatorApf"/>
                        </h:inputText>
                    </h:panelGroup>


                    <t:radio for="selectRadio" index="1" id="radio1"/>
                    <h:panelGroup>
                        <!---->                      <!--Há 22 espaços invisiveis (alt+255) entre estes comentarios-->
                        <h:outputLabel value="Código do Municipio"/>
                        <h:inputText id="municipio" label="Municipio" value="#{beanEmp.empreendimento.municipio}">
                            <f:validateRequired/>
                            <f:validateLongRange minimum="0"/>
                        </h:inputText>
                    </h:panelGroup>


                    <t:radio for="selectRadio" index="2" id="radio2"/>
                    <h:panelGroup>
                        <h:panelGrid columns="3">
                        <!---->                      <!--Há 22 espaços invisiveis (alt+255) entre estes comentarios-->
                        <h:outputLabel value="Situação"/>
                        <h:selectOneRadio id="selectSituacao" value="#{beanEmp.empreendimento.situacao}">
                                <f:selectItem itemLabel="Ativo" itemValue='1'/>
                                <f:selectItem itemLabel="Inativo" itemValue='2'/>
                            </h:selectOneRadio>
                        </h:panelGrid>
                    </h:panelGroup>
                </h:panelGrid>
                <h:commandButton value="Pesquisar" action="#{beanEmp.procurar}"/>
                <script>controlaRadio();</script>
            </h:form>
        </ui:define>

    </ui:composition>

</html>
